import { Navigate } from "react-router-dom";
/**
 * 认证路由组件，用于保护需要登录才能访问的路由
 */
const AuthRoute = ({ children }) => {
  const isToken = localStorage.getItem("token");
  if (isToken) {
    return children;
  } else {
    return <Navigate to="/login" replace />;
  }
};

export default AuthRoute;
